package com.xuecheng.content.convert;

import com.xuecheng.api.content.model.CourseBaseDTO;
import com.xuecheng.api.content.model.CourseBaseVO;
import com.xuecheng.api.content.model.TeachplanDTO;
import com.xuecheng.content.entity.CourseBase;
import com.xuecheng.content.entity.Teachplan;
import com.xuecheng.content.entity.exd.TeachplanNode;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * <h4>xuecheng</h4>
 * <p>MapStruct类与类的属性转换工具使用</p>
 *
 * @author : by wujianming
 * @date : 2021-12-08 21:19
 **/
@Mapper //mapStruct提供的注解
public interface CourseBaseConvert {
    //固定的值.后面参数为本类的字节码对象
    CourseBaseConvert INSTANCE = Mappers.getMapper(CourseBaseConvert.class);

    // 将courseBase转为CourseBaseDTO数据
    //如果两个类属性有不相同的名字.需要用source指定被转换类的属性
    //target指定转换类的属性
    @Mapping(source = "id",target = "courseBaseId")
//    @Mapping(source = "id",target = "courseBaseId")
    CourseBaseDTO entity2dto(CourseBase courseBase);


    //集合的属性会依赖于单个数据转换的方法
    //因此下面的转换功能依赖于上面的entity2dto方法.
    List<CourseBaseDTO> entitys2dtos(List<CourseBase> courseBase);

    //将CourseBaseDTO类的属性全封装到CourseBase；
    @Mapping(source = "courseBaseId",target = "id")
    CourseBase dto2entity(CourseBaseDTO courseBase);


    CourseBaseDTO VO2DTO(CourseBaseVO courseBaseVO);

    @Mapping(source = "id",target = "teachPlanId")
    TeachplanDTO po2DTO(Teachplan teachplan);

    @Mapping(source = "id",target = "teachPlanId")
    TeachplanDTO note2DTO(TeachplanNode teachplanNode);

    //运营审核
//    CourseBaseDTO voa2DTO(CourseAuditVO courseAuditVO);
}
